package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.City;
import cn.kgc.springcloud.server.CityServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cities")
public class CityController {
    @Autowired
    private CityServer cityServer;
    @GetMapping
    public List<City> queryCities(){
        return cityServer.queryCities();
    }

    @PostMapping
    public City addOne(@RequestBody City city){
        return cityServer.addOne(city);
    }

    @GetMapping("/{id}")
    public City selectOne(@PathVariable Integer id){
        return cityServer.selectOne(id);
    }
}
